#pragma once

#include "xarray.h"
#include "DlgHint.h"

#define		ID_SCR_TOFIRST		0
#define		ID_SCR_TOPREV		1
#define		ID_SCR_TONEXT		2
#define		ID_SCR_TOLAST		3
#define		ID_SCR_TOTHUMB		4

#define		ID_TIMER_HOTSPOT	9009

#define		BTNSTATUS_UP	0
#define		BTNSTATUS_DOWN	1
#define		BTNSTATUS_FOCUS	2

#define		BTNCLS_NORM		0
#define		BTNCLS_RADIO	1
#define		BTNCLS_CHECK	2
#define		BTNCLS_STATIC	3
#define		BTNCLS_NOIMAGE	4

typedef struct {
	TCHAR			caption[2][256];
	COLORREF		rgbCaption[2];
	TCHAR			fontCaption[64];
	BOOL			bShadow;
	BOOL			bBold;
	int				fntSize;
	int				btnClass;	//0: normal button, 1: radio button, 2: check button, 3: static, 4: none image
	int				idxCaption;
	int				id;
	int				status;	//0: up, 1: down, 2: focus
	BOOL			bSelected;
	int				idbUp;
	int				idbDn;
	int				idbFocus;
	int				idbSelect;
	int				idbSelectDn;
	int				idbSelectFocus;
	int				idbDisable;
	int				idbIcon;
	RECT			rect;
	COLORREF		rgbBkgr;
	COLORREF		rgbBorder;
	COLORREF		rgbAlpha;
	BOOL			bInVisible;
	BOOL			bDisable;
	int				align;

	//tooltip
	TCHAR			toolTip[256];
	BOOL			bShowToolTip;
} HOTSPOT;

//
class CHotSpots
{
public:
	int				m_iCaptured;
	CWnd*			m_pWnd;
	CDlgHint*		m_pToolTip;
	XARRAY*			m_HotSpots;
	UINT_PTR		m_idTimer;
	POINT			m_ptDrag;
public:
	CHotSpots();
	virtual	~CHotSpots();
public:
	void	initialize(CWnd* pWnd, HOTSPOT* HotSpots, int nCount);
	void	updatePos(HOTSPOT* HotSpots, int nCount);
	void	display(int idx = -1, CDC* pDC = NULL);
	HOTSPOT*	getHotSpot(int idx);
	int		findIndex(int id);
	int		getCount();
protected:
	int		checkInRect(POINT point);
public:
	int		onMouseMove(UINT nFlags, POINT point);
	int		onLButtonDown(UINT nFlags, POINT point);
	int		onLButtonUp(UINT nFlags, POINT point);
	void	setVisible(int idx, BOOL b);
	BOOL	getVisible(int idx);
	void	setDisable(int idx, BOOL b);
	void	onTimer(int tid);
	void	showToolTip(int idx, BOOL bShow = TRUE, CDC* pdc = NULL);
	void	setChecked(int idx, BOOL bCheck, BOOL bDowned);
	BOOL	isChecked(int idx);
	int		getChecked();
	void	setCaption(int idx, LPCTSTR szCaption);
	BOOL	isCaptured();
};

//
class CThumbScroll : public CHotSpots
{
public:
	CThumbScroll();
	virtual ~CThumbScroll();
public:
	RECT	m_rect;
	RECT	m_rcSlit;
	int		m_dir;	//0 : horiz, 1 : vertical
	long	m_pos;
	long	m_maxPos;
	long	m_pageSize;
	long	m_lineSize;
	int		m_idbPad;
	COLORREF	m_rgbPad;
	COLORREF	m_rgbSlit;
	COLORREF	m_rgbSlitPass;
	POINT	m_ptDragThumb;
public:
	void	initialize(CWnd* pWnd, RECT* pRect, int idbThumb[3],
						int idbPad = -1, int dir = 0, long maxPos = 0);
	void	initialize(CWnd* pWnd, RECT* pRect, RECT* pRcSlit, int idbThumb[3],
						COLORREF rgbPad, COLORREF rgbSlit[2], int dir = 0, long maxPos = 0);
	void	setPos(long pos);
	long	getPos();
	void	setMaxPos(long maxPos);
	long	getMaxPos();
	void	setPageSize(long size);
	long	getPageSize();
	void	setLineSize(long size);
	long	getLineSize();
	void	setIdbPad(int idbPad);
	void	display(CDC* pDC = NULL);
	void	moveThumbX(LONG x);
	void	moveThumbY(LONG y);
public:
	int		onMouseMove(UINT nFlags, POINT point);
	int		onLButtonDown(UINT nFlags, POINT point);
	int		onLButtonUp(UINT nFlags, POINT point);
};

//
class CHotScroll
{
public:
	CHotScroll();
	virtual	~CHotScroll();
public:
	CHotSpots		m_nvHots;
	CThumbScroll	m_thumbHots;
public:
	RECT	m_rect;
public:
	void	initialize(CWnd* pWnd, RECT* pRect, int idbThumb[3], int idbNavi[4][3], int idbPad = -1, int dir = 0, long maxPos = 0);
	void	setPos(long pos);
	long	getPos();
	void	setMaxPos(long maxPos);
	long	getMaxPos();
	void	setPageSize(long size);
	long	getPageSize();
	void	setLineSize(long size);
	long	getLineSize();
	void	display();
public:
	int		onMouseMove(UINT nFlags, POINT point);
	int		onLButtonDown(UINT nFlags, POINT point);
	int		onLButtonUp(UINT nFlags, POINT point);
};
